package com.lingshu.app.database.dao;

import androidx.room.Dao;
import androidx.room.Insert;
import androidx.room.OnConflictStrategy;
import androidx.room.Query;
import androidx.room.Update;

import com.lingshu.app.database.bean.MessageBean;

import java.util.List;

import io.reactivex.Completable;
import io.reactivex.Flowable;
import io.reactivex.Single;

/**
 * @author 于定金
 * @version 1.0
 * @Date 2024/1/15 13:39
 * @Description
 */
@Dao
public interface MessageDao {
    @Insert(onConflict = OnConflictStrategy.REPLACE)
    Completable insert(MessageBean... messages);

    @Update
    Completable update(MessageBean... messages);

    @Query("select * from messages where id = :id")
    Flowable<MessageBean> get(int id);

    @Query("select * from messages")
    Flowable<List<MessageBean>> getAll();

    @Query("select * from messages order by id desc limit :pageSize offset :offset")
    Flowable<List<MessageBean>> getPagedList(int pageSize, int offset);

    @Query("select count(*) from messages")
    Flowable<Integer> getCount();
}
